import 'reflect-metadata';
import { validationMetadatasToSchemas } from 'class-validator-jsonschema';
import { getMetadataArgsStorage } from "routing-controllers";
import { routingControllersToSpec } from "routing-controllers-openapi";

function getSpec() {
  const schemas = validationMetadatasToSchemas({
    refPointerPrefix: '#/components/schemas/',
  });

  const storage = getMetadataArgsStorage();

  const spec = routingControllersToSpec(storage, undefined, {
    components: {
      schemas: schemas as any,
      securitySchemes: {
        bearerAuth: {
          type: 'http',
          scheme: 'bearer',
        }
      }
    },
    info: {
      description: 'A boilerplate API',
      title: 'Boilerplate API',
      version: '2.0.0',
    }
  });
  return spec;
}

export { getSpec };
